const char	*inetntop(struct SOCKADDR_IN *in)
{
	static char buf[256];
	if (in->sin_family == AF_INET)
		return inet_ntop(AF_INET, &in->sin_addr, buf, sizeof(buf));
#ifdef INET6
	assert(in->sin_family == AF_INET6);
	/* ugly! */
	if (IN6_IS_ADDR_V4MAPPED(&in->sin_addr))
		return inet_ntop(AF_INET, ((char *) &in->sin_addr) + 12, buf, sizeof(buf));
	return inet_ntop(AF_INET6, in, buf, sizeof(buf));
#endif
}

int	inetpton(const char *ip, struct SOCKADDR_IN *in)
{
	in_addr_t v4;
	if (inet_pton(AF_INET, ip, &v4)) {
#ifdef INET6
		/* create mapped address */
		memcpy(&in->sin_addr, "\0\0\0\0\0\0\0\0\xff\xff\xff\xff", 12);
		memcpy(((char *)&in->sin_addr) + 12, &v4, 4);
#else
		in->sin_addr.s_addr = v4;
#endif
		return 1;
	}
#ifdef INET6
	return inet_pton(AF_INET6, ip, &in->sin_addr);
#endif
	return 0;
}

